package com.example.entity;

import com.example.handler.LiveRoomStatisticsCellMergeHandler;

import java.util.ArrayList;
import java.util.List;

/**
 * 直播间统计信息
 *
 * @author linfeng
 * @date 2022/1/9 10:55
 */
public class LiveRoomStatistics {

    /**
     * 公司名称
     */
    private String companyName;

    /**
     * 直播间id
     */
    private String roomId;

    /**
     * 直播间名称
     */
    private String roomName;

    /**
     * 直播间观看人次
     */
    private Long countViewers;

    /**
     * v
     */
    private Long countIconClickedTimes;

    /**
     * 产品名称
     */
    private List<String> productNameList;

    /**
     * 产品点击数
     */
    private List<Long> countProductClickedTimesList;

    /**
     * 展开“产品点击数”列表，方便后续进行单元格合并 (see {@link LiveRoomStatisticsCellMergeHandler})
     *
     * @return List&lt;{@link LiveRoomStatisticsExcelModel}&gt;
     */
    public List<LiveRoomStatisticsExcelModel> unwindProductClickedTimesList() {
        List<LiveRoomStatisticsExcelModel> result = new ArrayList<>();
        if (productNameList.isEmpty()) {
            LiveRoomStatisticsExcelModel excelModel = new LiveRoomStatisticsExcelModel();
            excelModel.setCompanyName(this.companyName);
            excelModel.setRoomId(this.roomId);
            excelModel.setRoomName(this.roomName);
            excelModel.setCountViewers(this.countViewers);
            excelModel.setCountIconClickedTimes(this.countIconClickedTimes);
            excelModel.setProductName(null);
            excelModel.setCountProductClickedTimes(null);
            result.add(excelModel);
            return result;
        }
        int index = 0;
        for (String productName : productNameList) {
            LiveRoomStatisticsExcelModel excelModel = new LiveRoomStatisticsExcelModel();
            excelModel.setRoomId(this.roomId);
            if (result.isEmpty()) {
                excelModel.setCompanyName(this.companyName);
                excelModel.setRoomName(this.roomName);
                excelModel.setCountViewers(this.countViewers);
                excelModel.setCountIconClickedTimes(this.countIconClickedTimes);
            }
            excelModel.setProductName(productName);
            excelModel.setCountProductClickedTimes(this.countProductClickedTimesList.get(index));
            result.add(excelModel);
            index++;
        }
        return result;
    }

    /* ———————————————————— Getter/Setter ————————————————————*/

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getRoomId() {
        return roomId;
    }

    public void setRoomId(String roomId) {
        this.roomId = roomId;
    }

    public String getRoomName() {
        return roomName;
    }

    public void setRoomName(String roomName) {
        this.roomName = roomName;
    }

    public Long getCountViewers() {
        return countViewers;
    }

    public void setCountViewers(Long countViewers) {
        this.countViewers = countViewers;
    }

    public Long getCountIconClickedTimes() {
        return countIconClickedTimes;
    }

    public void setCountIconClickedTimes(Long countIconClickedTimes) {
        this.countIconClickedTimes = countIconClickedTimes;
    }

    public List<String> getProductNameList() {
        return productNameList;
    }

    public void setProductNameList(List<String> productNameList) {
        this.productNameList = productNameList;
    }

    public List<Long> getCountProductClickedTimesList() {
        return countProductClickedTimesList;
    }

    public void setCountProductClickedTimesList(List<Long> countProductClickedTimesList) {
        this.countProductClickedTimesList = countProductClickedTimesList;
    }
}
